package com.imooc.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author lihongyu
 * @CreateTime 2021-08-03 10:18
 * @Description 事务测试
 *      REQUIRED: ,
 *      SUPPORTS(1),
 *      MANDATORY(2),
 *      REQUIRES_NEW(3),
 *      NOT_SUPPORTED(4),
 *      NEVER(5),
 *      NESTED(6);
 */
@Service
public class TransactionService {

    @Resource
    private StuService stuService;

    /**
     * 测试
     */
//    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    public void testRequiredTransaction(){
        stuService.saveParentData();
        stuService.saveChildData();
    }

}
